﻿using System;
using System.Application;
using System.Domain.Entity;
using System.Repository;
using System.Repository.Base;
using System.Text;
using System.Threading;
using Application.Infrastructure;
using Domain.Infrastructure;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Console;
using Microsoft.Extensions.Logging.Debug;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            SysUserRepository repository = new SysUserRepository(new DbContextConfig());
            //SysUserRepository repository = new SysUserRepository(FactoryProvider.CreateDbContext("Server=101.200.49.147;Port=3306; Database=JewelleryManage; UID=root; Password=;SslMode=none;"));
            for (int i = 0; i < 1000; i++)
            {
                SysUserService service = new SysUserService(new Log(), repository);
                var model = service.GetEntity("d18f2851-6da0-45a2-971c-946ab5e71dac");

                Pagination pagination = new Pagination()
                {
                    Sort = "CreatorTime",
                    Order = "desc",
                    Rows = 2
                };
                var modelS = service.GetList(pagination);
                if (model == null)
                {
                    model = new SysUserEntity()
                    {
                        MobilePhone = "123145"
                    };
                }
                var se = service.GetList();

                var s = service.Login("hr01", "123");
                model.NickName = DateTime.Now.ToString("yyyyMMddHHmmss");
                var state1 = service.Update(model);
                service.Delete(model);
                var state = service.Insert(model);
                Thread.Sleep(1000);

            }

          


            //Console.WriteLine("Hello World!");

            //Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);

            ////演示1
            //Func<string, LogLevel, bool> filter = (category, level) => true;
            //ILoggerFactory loggerFactory = new LoggerFactory();

            ////loggerFactory.AddProvider(new ConsoleLoggerProvider(filter, false));

            ////loggerFactory.AddProvider(new DebugLoggerProvider(filter));

            ////ILogger logger = loggerFactory.CreateLogger("App");

            ////演示2
            //ILogger logger = new LoggerFactory().AddConsole().AddDebug()
            //     .CreateLogger("App");

            //////演示3  Microsoft.Extensions.DependencyInjection   依赖注入
            ////ILogger logger = new ServiceCollection()

            ////      .AddLogging() 
            ////      .BuildServiceProvider() 
            ////      .GetService<ILoggerFactory>() 
            ////      .AddConsole() 
            ////      .AddDebug() 
            ////      .CreateLogger("App");

            //int eventId = 3721; 
            //logger.LogInformation(eventId, "升级到最新版本({version})", "1.0.0.rc2"); 
            //logger.LogWarning(eventId, "并发量接近上限({maximum}) ", 200); 
            //logger.LogError(eventId, "数据库连接失败(数据库：{Database}，用户名：{User})", "TestDb", "sa");


            Console.Read();
        }
    }
}
